Fix HTJ2K bytes-per-line integer overflow in internal_ht.cpp#2342
Closed
cary-ilm wants to merge 1 commit intoAcademySoftwareFoundation:mainfrom
Closed
Fix HTJ2K bytes-per-line integer overflow in internal_ht.cpp#2342cary-ilm wants to merge 1 commit intoAcademySoftwareFoundation:mainfrom
cary-ilm wants to merge 1 commit intoAcademySoftwareFoundation:mainfrom
Conversation
Accumulate bpl in `int64_t` with `int64` per-channel products, reject sums above `INT_MAX` with `EXR_ERR_CORRUPT_CHUNK` (mirrors PIZ `wcount*nx` guard). Harden `raster_line_offset` summation with `uint64_t`. Apply the same `bpl` logic to `ht_apply_impl`. Use `ptrdiff_t `for non-planar line strides after validation. Made-with: Cursor Signed-off-by: Cary Phillips <cary@ilm.com>
palemieux
suggested changes
Apr 8, 2026
| { | ||
| int32_t w = decode->channels[i].width; | ||
| int8_t bpe = decode->channels[i].bytes_per_element; | ||
| if (w < 0 || bpe < 0) return EXR_ERR_CORRUPT_CHUNK; |
Contributor
There was a problem hiding this comment.
w and bpe are the responsibility of the caller, shouldn't the check happen there?
Member
Author
There was a problem hiding this comment.
It's true that width and bytes_per_element should have valid values before entry, but the test here still seems worthwhile before a cast that would fail if they're invalid. It's a simply test, I'd vote for leaving it in place.
Do you understand the code path well enough to understand exactly where that validation should happen if not here?
Contributor
There was a problem hiding this comment.
Validation already happens at https://github.com/AcademySoftwareFoundation/openexr/blob/main/src/lib/OpenEXRCore/validation.c
Member
Author
|
closing in favor of #2345 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Accumulate
bplinint64_twithint64per-channel products, reject sums aboveINT_MAXwithEXR_ERR_CORRUPT_CHUNK(mirrors PIZwcount*nxguard). Hardenraster_line_offsetsummation withuint64_t. Apply the samebpllogic toht_apply_impl. Useptrdiff_tfor non-planar line strides after validation.Addresses CVE-2026-39886
Made-with: Cursor